<?php
use App\Model\Comcheck;?>
		<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>区域检查统计查询结果</title>
	<link rel="stylesheet" href="/css/style.css">
	<script src="/js/jquery.min.js"></script>
</head>
<body style="background: #F2F2F2;">
<div class="xuaneiqi">
	<span id="tjs" class="xuanzhongda">查询结果统计树</span>
	<span id="tjlb">查询结果统计列表</span>
</div>
<div class="diyikuaineir">

	@foreach ($result as $k=>$u)
		<div class="diliweiz">
			<img src="/images/awdaw.png" alt="" />
			<span><?php echo empty($provinceresult[$k])?'未知地市':$provinceresult[$k]->name;?></span>
		</div>
		<ul class="tyaww">
			<li>
				<ul class="meiytia" style="height: auto">
					@foreach ($u as $k1=>$u1)
						<li style="font-size: 14px"><?php echo empty($provinceresult[$k1])?'未知地区':$provinceresult[$k1]->name;?></li>
						@foreach ($u1 as $k2=>$u2)
							<li style="color: #607D8B"><?php echo empty($provinceresult[$k2])?'未知街道':$provinceresult[$k2]->name;?></li>
							<?php $yinhuan = 0;$ren = 0;$wu = 0;$com=0;$comagain=0;$all = 0;$wzg=0;$bfzg=0;$yzg=0;$againId = [];?>
							@foreach ($u2 as $k3=>$u3)
								@foreach ($u3 as $k6=>$u7)
								<!--初查-->
									@if($k3 == 'comcheck')
										<?php $com++;?>
										@foreach($comcheckdetailtree as $k4=>$u5)
											@if($u5['checkId'] == $u7['id'])
												<?php $yinhuan ++;?>
											@endif
											@if($u5['checkId'] == $u7['id'] && $u5['groupstatus'] == 1)
												<?php $ren ++;?>
											@elseif($u5['checkId'] == $u7['id'] && $u5['groupstatus'] == 2)
												<?php $wu++;?>
											@endif
										@endforeach
									@endif
								<!--初查-->
									<!--复查-->
									@if($k3 == 'again')
										<?php  if (in_array($u7['companyId'],$againId)){}else{array_push($againId,$u7['companyId']);$comagain++;}?>
										@foreach($comcheckagaindetailtree as $k4=>$u5)
											@if($u5['checkId'] == $u7['id'])
												<?php $all ++;?>
											@endif
											@if($u5['checkId'] == $u7['id'] && $u5['status'] == 1)
												<?php $wzg ++;?>
											@elseif($u5['checkId'] == $u7['id'] && $u5['status'] == 2)
												<?php $bfzg++;?>
											@elseif($u5['checkId'] == $u7['id'] && $u5['status'] == 3)
												<?php $yzg++;?>
											@endif
										@endforeach
									@endif
								<!--复查-->
								@endforeach

							@endforeach
							<li>
								@if(!empty($provinceresult[$k2]))
								<a href="/ninesmall/getcompany/<?php echo empty($provinceresult[$k2])?'':$provinceresult[$k2]->id;?>/{{$start_date}}/{{$end_date}}">共计检查企业{{$com}}家，共查出隐患{{$yinhuan}}条，其中基础档案相关的有{{$ren}}条,现场相关的有{{$wu}}条</a></li>
								@elseif(empty($provinceresult[$k2]))
								共计检查企业{{$com}}家，共查出隐患{{$yinhuan}}条，其中基础档案相关的有{{$ren}}条,现场相关的有{{$wu}}条</li>
								@endif
							<li>
								<a href="/ninesmall/getcompanyagain/<?php echo empty($provinceresult[$k2])?'':$provinceresult[$k2]->id;?>/{{$start_date}}/{{$end_date}}">共计复查企业{{$comagain}}家，已整改{{$yzg}}条，部分整改{{$bfzg}}条,未整改{{$wzg}}条，隐患整改率为
									<?php echo empty($all)?'0%':sprintf("%.2f",$yzg/$all*100).'%'?></a>
							</li>
						@endforeach
					@endforeach
				</ul>
			</li>
		</ul>
	@endforeach

</div>
<div class="dierkuaineir">
	<p class="yuausj">共检查到检查企业{{$count}}家</p>
	<!--<div class="tyaw">-->

	<ul class="tyaw">
		<li class="daoh"><span>序号</span><span>隐患统计</span><span>排查地点</span><span>排查人</span></li>
		<?php $i=1;?>
		@foreach ($list as $u)
			<li>
				<?php $chucha = 0;$fucha = 0;?>
				<span>{{$i}}</span>
				@foreach ($comcheckdetail as $v)
					@if($v->checkId == $u->id)
						<?php $chucha ++;?>
					@endif
				@endforeach
				@foreach ($comcheckagain as $v)
					@foreach ($comcheckagaindetail as $v1)
						@if($v->checkId == $u->id && $v->id == $v1->checkId)
							<?php $fucha ++;?>
						@endif
					@endforeach
				@endforeach
				<span><?php echo "<a href='/ninesmall/companyone/".$u->company->id."'>".str_replace('有限公司', '', empty($u->company->comName)?'':$u->company->comName);?>初查时共有{{$chucha}}条隐患，复查时已整改{{$fucha}}条</a> </span>
				<span style="height: auto">
					@foreach ($provinceresult as $a)
						@if($u->company->city == $a->id)
							{{$a->name}}
						@endif
						@if($u->company->district == $a->id)
							{{$a->name}}
						@endif
						@if($u->company->street == $a->id)
							{{$a->name}}
						@endif
					@endforeach
					{{$u->company->address}} </span>
				<span style="width: 10%">{{$u->users->name}} </span>
			</li>
			<?php $i++; ?>
		@endforeach
	</ul>




</div>
<div class="rwada jcjs dibuann" href=""><a class="cfae" class="" href="exportlist?start_date={{$start_date}}&end_date={{$end_date}}&province={{$province}}&city={{$city}}&town={{$town}}&street={{$street}}">导出统计表</a><a class="" href="">生成分析报告</a></div>
</body>
<script>
	$("#tjlb").click(
			function(){
				$(".diyikuaineir").css("display","none")
				$(".dierkuaineir").css("display","block")
				$("#tjlb").addClass("xuanzhongda")
				$("#tjs").removeClass()("xuanzhongda")
			}
	)
	$("#tjs").click(
			function(){
				$(".diyikuaineir").css("display","block")
				$(".dierkuaineir").css("display","none")
				$("#tjs").addClass("xuanzhongda")
				$("#tjlb").removeClass()("xuanzhongda")
			}
	)
</script>
</html>